package com.itheima;

import java.util.Scanner;


/**
 * 拓展题 1交换两个值
 */

public class HomeWork02 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你要输入的两个数字：");
        int left = sc.nextInt();
        int right = sc.nextInt();
        int temp = 0;
        temp = left;
        left = right;
        right = temp;
        System.out.println("交换后的数字为：");
        System.out.println(left);
        System.out.println(right);
        System.out.println("===================================");
        //    拓展题 2 掌握键盘录入的使用
        //    Scanner的熟练用法
        Scanner sc1 = new Scanner(System.in);
        System.out.println("请输入4位会员卡号");
        int sum = sc1.nextInt();
        System.out.println("卡号数字之和为：");
        System.out.println(priceNum(sum));
        if(priceNum(sum) >= 20){
            System.out.println("该卡号是幸运客户");
        }
        else{
            System.out.println("该卡号不是幸运客户");
        }

    }

    public static int priceNum(int price) {
        int ge = price % 10;
        int shi = (price / 10) % 10;
        int bai = (price / 100) % 10;
        int qian = (price / 1000) % 10;
        int sum = ge + shi + bai + qian;
        return sum;



    }

}
